<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑学生信息</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/style.css?v=1.0">
</head>
<body>
<div class="container mt-5">
    <h1 class="mb-4">编辑学生信息</h1>

    <div class="card">
        <div class="card-body">
            <form th:action="@{/students/update/{id}(id=${student.id})}"
                  th:object="${student}" method="post">
                <input type="hidden" th:field="*{id}">

                <div class="mb-3">
                    <label for="name" class="form-label">姓名</label>
                    <input type="text" class="form-control" id="name"
                           th:field="*{name}" required>
                </div>

                <div class="mb-3">
                    <label for="email" class="form-label">邮箱</label>
                    <input type="email" class="form-control" id="email"
                           th:field="*{email}" required>
                </div>

                <div class="mb-3">
                    <label for="phone" class="form-label">电话</label>
                    <input type="tel" class="form-control" id="phone"
                           th:field="*{phone}" required>
                </div>

                <div class="mb-3">
                    <label for="department" class="form-label">院系</label>
                    <select class="form-select" id="department" th:field="*{department}" required>
                        <option value="">请选择院系</option>

                        <option th:each="dept : ${departments}"
                                th:value="${dept}" th:text="${dept}"
                                th:selected="${dept == student.department}">
                        </option>
                    </select>
                </div>

                <div class="mb-3">
                    <label for="year" class="form-label">年级</label>
                    <input type="number" class="form-control" id="year"
                           th:field="*{year}" min="1" max="5" required>
                </div>

                <button type="submit" class="btn btn-primary">更新</button>
                <a th:href="@{/students}" class="btn btn-secondary ms-2">取消</a>
            </form>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>